#include <iostream>
#include <string>
using namespace std;

struct Person {
    int age;
    string name;
    bool man;
};
 
double& setValues(double vals[], int i) {  
    vals[0] =1.1;
   double& ref = vals[i];    
   return ref;   // 返回第 i 个元素的引用，ref 是一个引用变量，ref 引用 vals[i]
}

void change(Person& pp){
    pp.name ="Tom";
    pp.age = 2;
}

int main()
{
    cout << "Hello, world!" << endl;
    double vals[] = {10.1, 12.6, 33.1, 24.1, 50.0};

    cout << "改变前的值" << endl;
    for ( int i = 0; i < 5; i++ )
    {
        cout << "vals[" << i << "] = ";
        cout << vals[i] << endl;
    }
 
   setValues(vals,1) = 20.23; // 改变第 2 个元素
   setValues(vals,3) = 70.8;  // 改变第 4 个元素
 
   cout << "改变后的值" << endl;
   for ( int i = 0; i < 5; i++ )
   {
       cout << "vals[" << i << "] = ";
       cout << vals[i] << endl;
   }

   Person p = {

         name:"Mike1",
         man:true,
   };
   change(p);
    cout << p.name << endl;
    cout << p.age << endl;
    cout << p.man << endl;
    return 0;
}

